<!DOCTYPE html>
<html lang="en">
  <head>
    <title>KNN Structure Reference</title>
    <link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
    <link rel="stylesheet" type="text/css" href="../css/highlight.css" />
    <meta charset='utf-8'>
    <script src="../js/jquery.min.js" defer></script>
    <script src="../js/jazzy.js" defer></script>
    
  </head>
  <body>
    <a name="//apple_ref/swift/Struct/KNN" class="dashAnchor"></a>
    <a title="KNN Structure Reference"></a>
    <header>
      <div class="content-wrapper">
        <p><a href="../index.html"> Docs</a> (88% documented)</p>
      </div>
    </header>
    <div class="content-wrapper">
      <p id="breadcrumbs">
        <a href="../index.html"> Reference</a>
        <img id="carat" src="../img/carat.png" />
        KNN Structure Reference
      </p>
    </div>
    <div class="content-wrapper">
      <nav class="sidebar">
        <ul class="nav-groups">
          <li class="nav-group-name">
            <a href="../Classes.html">Classes</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Classes/BaseEstimator.html">BaseEstimator</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Protocols.html">Protocols</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Protocols/ClassifierMixin.html">ClassifierMixin</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Structs.html">Structures</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Structs/Distance.html">Distance</a>
              </li>
              <li class="nav-group-task">
                <a href="../Structs/KNN.html">KNN</a>
              </li>
            </ul>
          </li>
        </ul>
      </nav>
      <article class="main-content">
        <section>
          <section class="section">
            <h1>KNN</h1>
              <div class="declaration">
                <div class="language">
                  <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">KNN</span><span class="o">&lt;</span><span class="kt">Feature</span><span class="p">,</span> <span class="kt">Label</span><span class="o">&gt;</span> <span class="k">where</span> <span class="kt">Label</span> <span class="p">:</span> <span class="kt">Hashable</span></code></pre>

                </div>
              </div>
            <p>KNN</p>

          </section>
          <section class="section task-group-section">
            <div class="task-group">
              <ul>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:8AIDevLog3KNNV1k33_6E0E8406C7C8514A02A7D85FD49C52C1LLSivp"></a>
                    <a name="//apple_ref/swift/Property/k" class="dashAnchor"></a>
                    <a class="token" href="#/s:8AIDevLog3KNNV1k33_6E0E8406C7C8514A02A7D85FD49C52C1LLSivp">k</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Number of neighbors to use by default for :meth:<code>kneighbors</code> queries</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">private</span> <span class="k">var</span> <span class="nv">k</span><span class="p">:</span> <span class="kt">Int</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:8AIDevLog3KNNV14distanceMetric33_6E0E8406C7C8514A02A7D85FD49C52C1LLySdx_xtcvp"></a>
                    <a name="//apple_ref/swift/Property/distanceMetric" class="dashAnchor"></a>
                    <a class="token" href="#/s:8AIDevLog3KNNV14distanceMetric33_6E0E8406C7C8514A02A7D85FD49C52C1LLySdx_xtcvp">distanceMetric</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>distance</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">private</span> <span class="k">let</span> <span class="nv">distanceMetric</span><span class="p">:</span> <span class="p">(</span><span class="n">_</span> <span class="nv">x1</span><span class="p">:</span> <span class="kt">Feature</span><span class="p">,</span> <span class="n">_</span> <span class="nv">x2</span><span class="p">:</span> <span class="kt">Feature</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Double</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:8AIDevLog3KNNV1X33_6E0E8406C7C8514A02A7D85FD49C52C1LLSayxGvp"></a>
                    <a name="//apple_ref/swift/Property/X" class="dashAnchor"></a>
                    <a class="token" href="#/s:8AIDevLog3KNNV1X33_6E0E8406C7C8514A02A7D85FD49C52C1LLSayxGvp">X</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Data set</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">private</span> <span class="k">var</span> <span class="nv">X</span><span class="p">:</span> <span class="p">[</span><span class="kt">Feature</span><span class="p">]</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:8AIDevLog3KNNV1y33_6E0E8406C7C8514A02A7D85FD49C52C1LLSayq_Gvp"></a>
                    <a name="//apple_ref/swift/Property/y" class="dashAnchor"></a>
                    <a class="token" href="#/s:8AIDevLog3KNNV1y33_6E0E8406C7C8514A02A7D85FD49C52C1LLSayq_Gvp">y</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Target values</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">private</span> <span class="k">var</span> <span class="nv">y</span><span class="p">:</span> <span class="p">[</span><span class="kt">Label</span><span class="p">]</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:8AIDevLog3KNNV19debugRadiusCallbackySaySdGcSgvp"></a>
                    <a name="//apple_ref/swift/Property/debugRadiusCallback" class="dashAnchor"></a>
                    <a class="token" href="#/s:8AIDevLog3KNNV19debugRadiusCallbackySaySdGcSgvp">debugRadiusCallback</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>draw radius for debug</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">debugRadiusCallback</span><span class="p">:</span> <span class="p">(([</span><span class="kt">Double</span><span class="p">])</span> <span class="o">-&gt;</span> <span class="p">())?</span></code></pre>

                        </div>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:8AIDevLog3KNNV1k14distanceMetricACyxq_GSi_Sdx_xtctcfc"></a>
                    <a name="//apple_ref/swift/Method/init(k:distanceMetric:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:8AIDevLog3KNNV1k14distanceMetricACyxq_GSi_Sdx_xtctcfc">init(k:distanceMetric:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>constructorLabels for xTest</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span> <span class="p">(</span><span class="nv">k</span><span class="p">:</span> <span class="kt">Int</span><span class="p">,</span> <span class="nv">distanceMetric</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="n">_</span> <span class="nv">x1</span><span class="p">:</span> <span class="kt">Feature</span><span class="p">,</span> <span class="n">_</span> <span class="nv">x2</span><span class="p">:</span> <span class="kt">Feature</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Double</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>k</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>k</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>distanceMetric</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>distance</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:8AIDevLog3KNNV3fit1X1yySayxG_Sayq_GtF"></a>
                    <a name="//apple_ref/swift/Method/fit(X:y:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:8AIDevLog3KNNV3fit1X1yySayxG_Sayq_GtF">fit(X:y:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>train</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">fit</span><span class="p">(</span><span class="kt"><a href="../Structs/KNN.html#/s:8AIDevLog3KNNV1X33_6E0E8406C7C8514A02A7D85FD49C52C1LLSayxGvp">X</a></span><span class="p">:</span> <span class="p">[</span><span class="kt">Feature</span><span class="p">],</span> <span class="nv">y</span><span class="p">:</span> <span class="p">[</span><span class="kt">Label</span><span class="p">])</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>X</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Training set</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>y</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Target values</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:8AIDevLog3KNNV7predict5XTestSayq_GSayxG_tF"></a>
                    <a name="//apple_ref/swift/Method/predict(XTest:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:8AIDevLog3KNNV7predict5XTestSayq_GSayxG_tF">predict(XTest:)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Labels for xTest</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">predict</span><span class="p">(</span><span class="kt">XTest</span><span class="p">:</span> <span class="p">[</span><span class="kt">Feature</span><span class="p">])</span> <span class="o">-&gt;</span> <span class="p">[</span><span class="kt">Label</span><span class="p">]</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>XTest</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>Test set</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div>
                        <h4>Return Value</h4>
                        <p>Target values</p>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
          </section>
        </section>
        <section id="footer">
          <p>&copy; 2019 <a class="link" href="http://iosdevlog.com" target="_blank" rel="external">iOSDevLog</a>. All rights reserved. (Last updated: 2019-04-08)</p>
          <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.6</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
        </section>
      </article>
    </div>
  </body>
</div>
</html>
